package com.atguigu.gulimall.product;

import org.junit.Test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.stream.Collectors;

/**
 * @author study
 * @version 1.0
 * @date 2021/5/10 14:54
 */
public class Java8Demo {
    @Test
    public void stream() {
        HashMap<Integer, Integer> map = new HashMap<>(5);
        Arrays.asList(1, 2, 3, 4, 5, 6)
                .stream().map(data -> {
            map.put(data, data * 3);
            return null;
        }).collect(Collectors.toList());
        /*Arrays.asList(1, 2, 3, 4, 5, 6)
                .stream().forEach(data -> {
            map.put(data, data * 3);
        });*/
        System.out.println(map);
    }
}
